package com.qin.controller;

import com.alibaba.fastjson.JSONObject;
import com.qin.enums.RetCode;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap;
import java.util.Map;

@Controller("testController")
@RequestMapping("/test")
@ResponseBody
public class TestController {

    @RequestMapping(value="/test", consumes="application/json;charset=UTF-8", produces="application/json;charset=UTF-8")
    public String test(@RequestBody String body){

//        System.out.println("web层：test");
        System.out.println("接口调用：/test/test");

        Map retMap = new HashMap();
        retMap.put("retCode", RetCode.ERROR.getCode());
        retMap.put("retMsg", RetCode.ERROR.getMsg());
        retMap.put("errorMsg", "调用测试");

        String retString = new JSONObject(retMap).toString();
        System.out.println("接口出参：" + retString);

        return retString;
    }
}
